package com.zhiyou100.controller.contract;

import com.zhiyou100.dao.Impl.ContractDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @description:
 * @author: 马跃
 * @create: 2021-01-23 19:16
 **/
@WebServlet("/contractDeleteBatches")
public class ContractDeleteBatchesServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String[] keys = request.getParameterValues("key");
        for (int i = 0; i < keys.length; i++) {
            int key = Integer.parseInt(keys[i]);
            new ContractDaoImpl().delete(key);
        }
        request.getRequestDispatcher("/contractQueryAll").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
